package org.example;

import java.io.FileInputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;

public class DBHelper {
    private static Connection conn;

    public static Connection getConnection() throws Exception {
        if (conn == null) {
            Properties props = new Properties();
            props.load(new FileInputStream("src/main/resources/config.properties"));

            String driver = props.getProperty("driver");
            String url = props.getProperty("url");
            String user = props.getProperty("user");
            String password = props.getProperty("password");

            Class.forName(driver);
            conn = DriverManager.getConnection(url, user, password);
        }
        return conn;
    }
}
